<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <a href="http://www.a.com/1.html">1</a>
    <a href="http://www.c.com/2.html">3</a>
    <a href="http://www.b.com/3.html">2</a>
    <a href="http://www.a.com/4.html">4</a>

    <script>
      /*
       所有的标签元素对象都有matches
       1. 判断元素对象是否可以被参数选择器选中
       2. 如果匹配选中返回true 否则返回false
      */
      const links = document.querySelectorAll("a");

      for (let link of links) {
        if (link.matches('[href*="a.com"]')) {
          console.log(link);
        }
      }
    </script>
  </body>
</html>
